/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package practica.pkg1.mercurial;

import javax.swing.table.DefaultTableModel;

/**
 *
 * @author Administrador
 */
public class ListOfProducts extends javax.swing.JPanel {
    
    String[] ColumsLabel={"TIPO MADERA","PRECIO POR PIE"};
    Object[][] Products= new Object[calculateTop()][2];
    
    public void FillMatrix(){
      int i=0;
        for(Wood w: MainFrame.system.getListOfWood()){
          Products[i][0]=w.getType();
          Products[i][1]=""+w.getPricePerFoot()+ " US";
          i++;
       }
    
    }
     
    
    /**
     * Creates new form ListOfProducts
     */
    public ListOfProducts() {
        initComponents();
        Initialization();
    }

    private int calculateTop(){
      int i=0;
        for(Wood w: MainFrame.system.getListOfWood()){
            i++;
     }
     return i;
    } 
    private void Initialization() {
        FillMatrix();
        DefaultTableModel ProModel=new DefaultTableModel(Products, ColumsLabel);
        TableProducts.setModel(ProModel);   
    }
    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jScrollPane1 = new javax.swing.JScrollPane();
        TableProducts = new javax.swing.JTable();

        TableProducts.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        jScrollPane1.setViewportView(TableProducts);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 302, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 114, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(24, Short.MAX_VALUE))
        );
    }// </editor-fold>//GEN-END:initComponents
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JTable TableProducts;
    private javax.swing.JScrollPane jScrollPane1;
    // End of variables declaration//GEN-END:variables

   
}
